package org.jadestudio.dsdown.action;

import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jadestudio.dsdown.entity.ManageAdminLogin;
import org.jadestudio.dsdown.form.TestActionForm;
import org.jadestudio.dsdown.service.TestService;

public class TestAction extends Action {
	
	public TestAction(){
	
	}
	private TestService testService;
    public ActionForward execute(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws Exception{
    	TestActionForm actionForm = (TestActionForm)form;
    	List<ManageAdminLogin> list = testService.getTestDate();
    	MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
	    MemoryUsage heap = mem.getHeapMemoryUsage();
	   // System.out.println(" max:" + heap.getMax()/1048576 + " used:" + heap.getUsed()/1048576);
	     
    	if (list != null && list.size()>0){
    		request.setAttribute("lt", list);
    		request.setAttribute("max",  heap.getMax()/1048576);
    		request.setAttribute("used", heap.getUsed()/1048576);
    	}
        return mapping.findForward("success");
    }

	public TestService getTestService() {
		return testService;
	}

	public void setTestService(TestService testService) {
		this.testService = testService;
	}


    
}
